from typing import List


class Solution:
    def twoEditWords(self, queries: List[str], dictionary: List[str]) -> List[str]:
        result = []

        def check(w: str, d: str) -> bool:
            count = 0
            for i in range(len(w)):
                if w[i] != d[i]:
                    count += 1

            return count <= 2

        for word in queries:
            for dic in dictionary:
                if check(word, dic):
                    result.append(word)
                    break

        return result


print(Solution().twoEditWords(
    ["word", "note", "ants", "wood"], ["wood", "joke", "moat"]))
